package cn.itcast.wanxinp2p.account.service.impl;

import cn.itcast.wanxinp2p.account.entity.Account;
import cn.itcast.wanxinp2p.account.mapper.AccountMapper;
import cn.itcast.wanxinp2p.account.service.AccountRegisterTCC;
import cn.itcast.wanxinp2p.api.account.model.AccountRegisterDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p> </p>
 *
 * @author <a href=mailto:zhaoboying@itcast.cn> Tao </a>
 * @version 1.0.0
 * @motto Talk is cheap, show me the code!
 * @since 2022-03-31 10:58:07
 */
@Service
@Slf4j
public class AccountRegisterTCCImpl extends ServiceImpl<AccountMapper, Account> implements AccountRegisterTCC {

    @Autowired
    private AccountMapper accountMapper;


    @Override
    public void confirmMethod(AccountRegisterDTO accountRegisterDTO) {
       log.info("注册业务的TCC account 的 confirmMethod。。。。。。。。。。。。。。。。");
    }

    @Override
    public void cancelMethod(AccountRegisterDTO accountRegisterDTO) {
        log.info("account 的 cancelMethod begin。。。。。。。。。。。。。。。。");
        accountMapper.delete(new LambdaQueryWrapper<Account>().eq(Account::getUsername, accountRegisterDTO.getUsername()));
        log.info("注册业务的TCC account 的 confirmMethod  end。。。。。。。。。。。。。。。。");
    }
}
